/*
 * Created by JFormDesigner on Sat Oct 21 11:02:11 CST 2023
 */

package cn.edu.cdp.gui.panel;

import java.util.*;

import cn.edu.cdp.dao.CollegeDao;
import cn.edu.cdp.dao.MajorDao;
import cn.edu.cdp.domain.Account;
import cn.edu.cdp.domain.College;
import cn.edu.cdp.domain.Major;
import cn.edu.cdp.domain.Student;
import cn.edu.cdp.gui.combo_box.ComboBoxCollege;
import cn.edu.cdp.gui.combo_box.ComboBoxMajor;
import cn.edu.cdp.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.awt.*;
import java.sql.Date;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;


/**
 * @author fanyi
 */
@Component
public class AdminPanel extends JPanel {
    ComboBoxCollege comboBoxCollege;
    ComboBoxMajor comboBoxMajor;

    private final AdminService adminService;
    private final CollegeDao collegeDao;
    private final MajorDao majorDao;
    private final QueryPanel queryPanel;

    @Autowired
    public AdminPanel(AdminService adminService, CollegeDao collegeDao, MajorDao majorDao, QueryPanel queryPanel) {
        initComponents();
        this.adminService = adminService;
        this.collegeDao = collegeDao;
        this.majorDao = majorDao;
        this.queryPanel = queryPanel;
    }

    public void decoration() {
        tabbedPane1.addTab("查询", queryPanel);
        comboBoxCollege = new ComboBoxCollege(collegeDao);
        comboBoxMajor = new ComboBoxMajor(majorDao);

        refreshData();

        // 学生面板，筛选和查询功能
        {

            panelStudent.add(comboBoxCollege, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
            panelStudent.add(comboBoxMajor, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

            comboBoxCollege.addActionListener(e -> {
                String collegeName = (String) comboBoxCollege.getSelectedItem();
                String majorName = (String) comboBoxMajor.getSelectedItem();
                List<Student> students = adminService.filterStudent(collegeName, majorName, "");
                fillStudentTable(students);

                // 选择学院后，对专业下拉列表筛选
                if (collegeName == null || collegeName.isEmpty()) {
                    comboBoxMajor.refreshData(majorDao);
                } else {
                    List<Major> majorList = adminService.filterMajorByCollegeName(collegeName);
                    comboBoxMajor.filter(majorList);
                }
            });

            comboBoxMajor.addActionListener(e -> {
                String collegeName = (String) comboBoxCollege.getSelectedItem();
                String majorName = (String) comboBoxMajor.getSelectedItem();
                List<Student> students = adminService.filterStudent(collegeName, majorName, "");
                fillStudentTable(students);
            });

            buttonQuery.addActionListener(e -> {
                String collegeName = (String) comboBoxCollege.getSelectedItem();
                String majorName = (String) comboBoxMajor.getSelectedItem();
                String studentIdOrName = textFieldQuery.getText();

                // 查询学院、专业、学生ID（精准）或名字（模糊）
                List<Student> students = adminService.filterStudent(collegeName, majorName, studentIdOrName);
                fillStudentTable(students);
            });

            buttonReset.addActionListener(e -> {
                comboBoxCollege.setSelectedIndex(0);
                comboBoxMajor.setSelectedIndex(0);
                textFieldQuery.setText("");
                refreshData();
            });
        }

        buttonCollegeAdd.addActionListener(e -> {
            int row = tableCollege.getSelectedRow();
            String collegeId = (String) tableCollege.getValueAt(row, 0);
            String name = (String) tableCollege.getValueAt(row, 1);
            String president = (String) tableCollege.getValueAt(row, 2);

            if (row + 1 == tableCollege.getRowCount()) {// 如果在最后的空行，那就可以添加
                adminService.collegeInsert(new College(collegeId, name, president));
            } else {
                adminService.collegeUpdate(new College(collegeId, name, president));
            }
            refreshData();
        });

        buttonCollegeDelete.addActionListener(e -> {
            int row = tableCollege.getSelectedRow();
            String collegeId = (String) tableCollege.getValueAt(row, 0);
            adminService.collegeDeleteById(collegeId);
            refreshData();
        });

        buttonMajorAdd.addActionListener(e -> {
            int row = tableMajor.getSelectedRow();
            String majorId = (String) tableMajor.getValueAt(row, 0);
            String name = (String) tableMajor.getValueAt(row, 1);
            String category = (String) tableMajor.getValueAt(row, 2);
            String collegeName = (String) tableMajor.getValueAt(row, 3);

            if (row + 1 == tableMajor.getRowCount()) {
                adminService.majorInsert(majorId, name, category, collegeName);
            } else {
                adminService.majorUpdate(majorId, name, category, collegeName);
            }
            refreshData();
        });

        buttonMajorDelete.addActionListener(e -> {
            int row = tableMajor.getSelectedRow();
            String majorId = (String) tableMajor.getValueAt(row, 0);
            adminService.majorDeleteById(majorId);
            refreshData();
        });

        buttonCourseAdd.addActionListener(e -> {
            int row = tableCourse.getSelectedRow();
            String courseId = (String) tableCourse.getValueAt(row, 0);
            String name = (String) tableCourse.getValueAt(row, 1);
            Double credit = Double.valueOf((String) tableCourse.getValueAt(row, 2));
            String semester = (String) tableCourse.getValueAt(row, 3);
            String collegeName = (String) tableCourse.getValueAt(row, 4);

            if (row + 1 == tableCourse.getRowCount()) {
                adminService.courseInsert(courseId, name, credit, semester, collegeName);
            } else {
                adminService.courseUpdate(courseId, name, credit, semester, collegeName);
            }
            refreshData();
        });

        buttonCourseDelete.addActionListener(e -> {
            int row = tableCourse.getSelectedRow();
            String courseId = (String) tableCourse.getValueAt(row, 0);
            adminService.courseDeleteById(courseId);
            refreshData();
        });

        buttonStudentAdd.addActionListener(e -> {
            int row = tableStudent.getSelectedRow();
            String studentId = (String) tableStudent.getValueAt(row, 0);
            String name = (String) tableStudent.getValueAt(row, 1);
            String sex = (String) tableStudent.getValueAt(row, 2);
            Date birthday;
            Double ceeScore;
            try {
                birthday = Date.valueOf((String) tableStudent.getValueAt(row, 3));
            } catch (Exception ex) {
                birthday = null;
            }
            try {
                ceeScore = Double.valueOf((String) tableStudent.getValueAt(row, 4));
            } catch (Exception ex) {
                ceeScore = null;
            }

            String nation = (String) tableStudent.getValueAt(row, 5);
            String nativePlace = (String) tableStudent.getValueAt(row, 6);
            String majorName = (String) tableStudent.getValueAt(row, 7);

            if (row + 1 == tableStudent.getRowCount()) {
                adminService.studentInsert(studentId, name, sex, birthday, ceeScore, nation, nativePlace, majorName);
            } else {
                adminService.studentUpdate(studentId, name, sex, birthday, ceeScore, nation, nativePlace, majorName);
            }
            refreshData();
        });

        buttonStudentDelete.addActionListener(e -> {
            int row = tableStudent.getSelectedRow();
            String studentId = (String) tableStudent.getValueAt(row, 0);
            adminService.studentDeleteById(studentId);
            refreshData();
        });

        buttonAccountAdd.addActionListener(e -> {
            int row = tableAccount.getSelectedRow();
            String username = (String) tableAccount.getValueAt(row, 0);
            String password = (String) tableAccount.getValueAt(row, 1);
            String role = (String) tableAccount.getValueAt(row, 2);

            if (row + 1 == tableAccount.getRowCount()) {// 如果在最后的空行，那就可以添加
                adminService.accountInsert(new Account(username, password, role));
            } else {
                adminService.accountUpdate(new Account(username, password, role));
            }
            refreshData();
        });

        buttonAccountDelete.addActionListener(e -> {
            int row = tableAccount.getSelectedRow();
            String username = (String) tableAccount.getValueAt(row, 0);
            adminService.accountDeleteByUsername(username);
            refreshData();
        });
    }


    public void refreshComboBox() {
        comboBoxCollege.refreshData(collegeDao);
        comboBoxMajor.refreshData(majorDao);
    }

    public void refreshData() {
        // 更新下拉列表数据
        refreshComboBox();

        // 表格数据
        // 学院
        {
            List<College> colleges = adminService.allCollege();
            Vector<Vector<String>> tableData = new Vector<>();
            Vector<String> tableTitle = new Vector<>();

            for (College college : colleges) {
                Vector<String> row = new Vector<>();
                row.add(college.getCollegeId());
                row.add(college.getName());
                row.add(college.getPresident());
                tableData.add(row);
            }
            tableData.add(new Vector<>());

            tableTitle.add("学院号");
            tableTitle.add("学院名");
            tableTitle.add("院长");

            tableCollege.setModel(new DefaultTableModel(tableData, tableTitle) {
                @Override
                public boolean isCellEditable(int row, int column) {
                    return row >= tableData.size() - 1 || column != 0;   // 禁用在表格中编辑
                }
            });
        }
        // 专业
        {
            List<Map<String, Object>> majors = adminService.allMajor();
            Vector<Vector<String>> tableData = new Vector<>();
            Vector<String> tableTitle = new Vector<>();

            for (Map<String, Object> major : majors) {
                Vector<String> row = new Vector<>();
                row.add((String) major.get("majorId"));
                row.add((String) major.get("name"));
                row.add((String) major.get("category"));
                row.add((String) major.get("collegeName"));
                tableData.add(row);
            }
            tableData.add(new Vector<>());

            tableTitle.add("专业编号");
            tableTitle.add("专业名");
            tableTitle.add("类别");
            tableTitle.add("所属学院");

            tableMajor.setModel(new DefaultTableModel(tableData, tableTitle) {
                @Override
                public boolean isCellEditable(int row, int column) {
                    return row >= tableData.size() - 1 || column != 0;   // 禁用在表格中编辑
                }
            });

            // 下拉菜单
            tableMajor.getColumnModel().getColumn(3).setCellEditor(new DefaultCellEditor(new ComboBoxCollege(collegeDao)));
        }
        // 课程
        {
            List<Map<String, Object>> courses = adminService.allCourse();
            Vector<Vector<String>> tableData = new Vector<>();
            Vector<String> tableTitle = new Vector<>();

            for (Map<String, Object> course : courses) {
                Vector<String> row = new Vector<>();
                row.add((String) course.get("courseId"));
                row.add((String) course.get("name"));
                row.add(course.get("credit").toString());
                row.add((String) course.get("semester"));
                row.add((String) course.get("collegeName"));
                tableData.add(row);
            }
            tableData.add(new Vector<>());

            tableTitle.add("课程编号");
            tableTitle.add("课程名");
            tableTitle.add("学分");
            tableTitle.add("学期");
            tableTitle.add("所属学院");

            tableCourse.setModel(new DefaultTableModel(tableData, tableTitle) {
                @Override
                public boolean isCellEditable(int row, int column) {
                    return row >= tableData.size() - 1 || column != 0;   // 禁用在表格中编辑
                }
            });

            // 下拉菜单
            tableCourse.getColumnModel().getColumn(4).setCellEditor(new DefaultCellEditor(new ComboBoxCollege(collegeDao)));
        }
        // 学生
        {
            List<Student> students = adminService.allStudent();
            fillStudentTable(students);
        }
        // 账户
        {
            List<Map<String, Object>> accounts = adminService.allAccount();
            Vector<Vector<String>> tableData = new Vector<>();
            Vector<String> tableTitle = new Vector<>();

            for (Map<String, Object> account : accounts) {
                Vector<String> row = new Vector<>();
                row.add((String) account.get("username"));
                row.add((String) account.get("password"));
                row.add((String) account.get("role"));

                tableData.add(row);
            }
            tableData.add(new Vector<>());

            tableTitle.add("用户名");
            tableTitle.add("密码");
            tableTitle.add("身份");

            tableAccount.setModel(new DefaultTableModel(tableData, tableTitle) {
                @Override
                public boolean isCellEditable(int row, int column) {
                    return row >= tableData.size() - 1 || column != 0;
                }
            });
        }
    }

    private void fillStudentTable(List<Student> students) {
        Vector<Vector<String>> tableData = new Vector<>();
        Vector<String> tableTitle = new Vector<>();

        for (Student student : students) {
            Vector<String> row = new Vector<>();
            row.add(student.getStudentId());
            row.add(student.getName());
            row.add(student.getSex());
            try {
                row.add(student.getBirthday().toString());
            } catch (Exception e) {
                row.add(null);
            }
            try {
                row.add(student.getCeeScore().toString());
            } catch (Exception e) {
                row.add(null);
            }
            row.add(student.getNation());
            row.add(student.getNativePlace());
            row.add(student.getMajorName());
            tableData.add(row);
        }
        tableData.add(new Vector<>());


        tableTitle.add("学号");
        tableTitle.add("姓名");
        tableTitle.add("性别");
        tableTitle.add("生日");
        tableTitle.add("入学成绩");
        tableTitle.add("民族");
        tableTitle.add("籍贯");
        tableTitle.add("专业名称");

        tableStudent.setModel(new DefaultTableModel(tableData, tableTitle) {
            @Override
            public boolean isCellEditable(int row, int column) {
                return row >= tableData.size() - 1 || column != 0;   // 禁用在表格中编辑
            }
        });

        // 下拉菜单
        tableStudent.getColumnModel().getColumn(7).setCellEditor(new DefaultCellEditor(new ComboBoxMajor(majorDao)));
    }


    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        ResourceBundle bundle = ResourceBundle.getBundle("swing_text");
        tabbedPane1 = new JTabbedPane();
        panel1 = new JPanel();
        scrollPane1 = new JScrollPane();
        tableCollege = new JTable();
        buttonCollegeAdd = new JButton();
        buttonCollegeDelete = new JButton();
        panel2 = new JPanel();
        scrollPane2 = new JScrollPane();
        tableMajor = new JTable();
        buttonMajorAdd = new JButton();
        buttonMajorDelete = new JButton();
        panel3 = new JPanel();
        scrollPane3 = new JScrollPane();
        tableCourse = new JTable();
        buttonCourseAdd = new JButton();
        buttonCourseDelete = new JButton();
        panelStudent = new JPanel();
        label1 = new JLabel();
        textFieldQuery = new JTextField();
        buttonQuery = new JButton();
        buttonReset = new JButton();
        scrollPane4 = new JScrollPane();
        tableStudent = new JTable();
        buttonStudentAdd = new JButton();
        buttonStudentDelete = new JButton();
        panel5 = new JPanel();
        scrollPane5 = new JScrollPane();
        tableAccount = new JTable();
        buttonAccountAdd = new JButton();
        buttonAccountDelete = new JButton();

        //======== this ========
        setMinimumSize(new Dimension(840, 500));
        setPreferredSize(new Dimension(840, 500));
        setMaximumSize(new Dimension(840, 500));
        setLayout(new BorderLayout());

        //======== tabbedPane1 ========
        {
            tabbedPane1.setTabPlacement(SwingConstants.LEFT);

            //======== panel1 ========
            {
                panel1.setLayout(new GridBagLayout());
                ((GridBagLayout)panel1.getLayout()).columnWidths = new int[] {25, 105, 105, 105, 105, 105, 105, 105, 105, 20, 0};
                ((GridBagLayout)panel1.getLayout()).rowHeights = new int[] {25, 305, 20, 0};
                ((GridBagLayout)panel1.getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
                ((GridBagLayout)panel1.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 1.0E-4};

                //======== scrollPane1 ========
                {
                    scrollPane1.setViewportView(tableCollege);
                }
                panel1.add(scrollPane1, new GridBagConstraints(3, 1, 4, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 5), 0, 0));

                //---- buttonCollegeAdd ----
                buttonCollegeAdd.setText(bundle.getString("AdminPanel.buttonCollegeAdd.text"));
                panel1.add(buttonCollegeAdd, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 5), 0, 0));

                //---- buttonCollegeDelete ----
                buttonCollegeDelete.setText(bundle.getString("AdminPanel.buttonCollegeDelete.text"));
                panel1.add(buttonCollegeDelete, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 5), 0, 0));
            }
            tabbedPane1.addTab(bundle.getString("AdminPanel.panel1.tab.title"), panel1);

            //======== panel2 ========
            {
                panel2.setLayout(new GridBagLayout());
                ((GridBagLayout)panel2.getLayout()).columnWidths = new int[] {25, 105, 105, 105, 105, 105, 105, 105, 105, 20, 0};
                ((GridBagLayout)panel2.getLayout()).rowHeights = new int[] {25, 305, 20, 0};
                ((GridBagLayout)panel2.getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
                ((GridBagLayout)panel2.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 1.0E-4};

                //======== scrollPane2 ========
                {
                    scrollPane2.setViewportView(tableMajor);
                }
                panel2.add(scrollPane2, new GridBagConstraints(3, 1, 4, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 5), 0, 0));

                //---- buttonMajorAdd ----
                buttonMajorAdd.setText(bundle.getString("AdminPanel.buttonMajorAdd.text"));
                panel2.add(buttonMajorAdd, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 5), 0, 0));

                //---- buttonMajorDelete ----
                buttonMajorDelete.setText(bundle.getString("AdminPanel.buttonMajorDelete.text"));
                panel2.add(buttonMajorDelete, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 5), 0, 0));
            }
            tabbedPane1.addTab(bundle.getString("AdminPanel.panel2.tab.title"), panel2);

            //======== panel3 ========
            {
                panel3.setLayout(new GridBagLayout());
                ((GridBagLayout)panel3.getLayout()).columnWidths = new int[] {25, 105, 105, 105, 105, 105, 105, 105, 105, 20, 0};
                ((GridBagLayout)panel3.getLayout()).rowHeights = new int[] {25, 305, 20, 0};
                ((GridBagLayout)panel3.getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
                ((GridBagLayout)panel3.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 1.0E-4};

                //======== scrollPane3 ========
                {
                    scrollPane3.setViewportView(tableCourse);
                }
                panel3.add(scrollPane3, new GridBagConstraints(1, 1, 8, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 5), 0, 0));

                //---- buttonCourseAdd ----
                buttonCourseAdd.setText(bundle.getString("AdminPanel.buttonCourseAdd.text"));
                panel3.add(buttonCourseAdd, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 5), 0, 0));

                //---- buttonCourseDelete ----
                buttonCourseDelete.setText(bundle.getString("AdminPanel.buttonCourseDelete.text"));
                panel3.add(buttonCourseDelete, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 5), 0, 0));
            }
            tabbedPane1.addTab(bundle.getString("AdminPanel.panel3.tab.title"), panel3);

            //======== panelStudent ========
            {
                panelStudent.setLayout(new GridBagLayout());
                ((GridBagLayout)panelStudent.getLayout()).columnWidths = new int[] {25, 105, 105, 105, 105, 105, 105, 105, 105, 20, 0};
                ((GridBagLayout)panelStudent.getLayout()).rowHeights = new int[] {25, 25, 305, 20, 0};
                ((GridBagLayout)panelStudent.getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
                ((GridBagLayout)panelStudent.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 1.0E-4};

                //---- label1 ----
                label1.setText(bundle.getString("AdminPanel.label1.text"));
                panelStudent.add(label1, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 5), 0, 0));
                panelStudent.add(textFieldQuery, new GridBagConstraints(4, 1, 2, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 5), 0, 0));

                //---- buttonQuery ----
                buttonQuery.setText(bundle.getString("AdminPanel.buttonQuery.text"));
                panelStudent.add(buttonQuery, new GridBagConstraints(6, 1, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 5), 0, 0));

                //---- buttonReset ----
                buttonReset.setText(bundle.getString("AdminPanel.buttonReset.text"));
                panelStudent.add(buttonReset, new GridBagConstraints(7, 1, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 5), 0, 0));

                //======== scrollPane4 ========
                {
                    scrollPane4.setViewportView(tableStudent);
                }
                panelStudent.add(scrollPane4, new GridBagConstraints(1, 2, 8, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 5), 0, 0));

                //---- buttonStudentAdd ----
                buttonStudentAdd.setText(bundle.getString("AdminPanel.buttonStudentAdd.text"));
                panelStudent.add(buttonStudentAdd, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 5), 0, 0));

                //---- buttonStudentDelete ----
                buttonStudentDelete.setText(bundle.getString("AdminPanel.buttonStudentDelete.text"));
                panelStudent.add(buttonStudentDelete, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 5), 0, 0));
            }
            tabbedPane1.addTab(bundle.getString("AdminPanel.panelStudent.tab.title"), panelStudent);

            //======== panel5 ========
            {
                panel5.setLayout(new GridBagLayout());
                ((GridBagLayout)panel5.getLayout()).columnWidths = new int[] {25, 105, 105, 105, 105, 105, 105, 105, 105, 20, 0};
                ((GridBagLayout)panel5.getLayout()).rowHeights = new int[] {25, 305, 20, 0};
                ((GridBagLayout)panel5.getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
                ((GridBagLayout)panel5.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 1.0E-4};

                //======== scrollPane5 ========
                {
                    scrollPane5.setViewportView(tableAccount);
                }
                panel5.add(scrollPane5, new GridBagConstraints(3, 1, 4, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 5, 5), 0, 0));

                //---- buttonAccountAdd ----
                buttonAccountAdd.setText(bundle.getString("AdminPanel.buttonAccountAdd.text"));
                panel5.add(buttonAccountAdd, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 5), 0, 0));

                //---- buttonAccountDelete ----
                buttonAccountDelete.setText(bundle.getString("AdminPanel.buttonAccountDelete.text"));
                panel5.add(buttonAccountDelete, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(0, 0, 0, 5), 0, 0));
            }
            tabbedPane1.addTab(bundle.getString("AdminPanel.panel5.tab.title"), panel5);
        }
        add(tabbedPane1, BorderLayout.CENTER);
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    private JTabbedPane tabbedPane1;
    private JPanel panel1;
    private JScrollPane scrollPane1;
    private JTable tableCollege;
    private JButton buttonCollegeAdd;
    private JButton buttonCollegeDelete;
    private JPanel panel2;
    private JScrollPane scrollPane2;
    private JTable tableMajor;
    private JButton buttonMajorAdd;
    private JButton buttonMajorDelete;
    private JPanel panel3;
    private JScrollPane scrollPane3;
    private JTable tableCourse;
    private JButton buttonCourseAdd;
    private JButton buttonCourseDelete;
    private JPanel panelStudent;
    private JLabel label1;
    private JTextField textFieldQuery;
    private JButton buttonQuery;
    private JButton buttonReset;
    private JScrollPane scrollPane4;
    private JTable tableStudent;
    private JButton buttonStudentAdd;
    private JButton buttonStudentDelete;
    private JPanel panel5;
    private JScrollPane scrollPane5;
    private JTable tableAccount;
    private JButton buttonAccountAdd;
    private JButton buttonAccountDelete;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
